﻿Imports System.IO

Public Class CodeHandler


#Region "private attributes"
    Private aPathTemplate As String  ' cesta k template solution
    Private aPathDestination As String
    Private aProjectName As String
    Private aFileNames As Files
    Private aSolutionName As String
#End Region

#Region "constructors"
    ''' <summary>
    ''' konstruktor
    ''' </summary>
    ''' <param name="pPathTemplate">cesta k rood adresaru s templatmi</param>
    ''' <param name="pPathDestination">cielova cesta kde sa vytvori projekt</param>
    ''' <remarks></remarks>
    Public Sub New(ByVal pFileNames As Files, ByVal pPathTemplate As String, ByVal pPathDestination As String, ByVal pProjectName As String, ByVal pSolutionName As String)
        Me.aFileNames = pFileNames
        Me.aPathDestination = pPathDestination
        Me.aPathTemplate = pPathTemplate
        Me.aProjectName = pProjectName
        Me.aSolutionName = pSolutionName
    End Sub

#End Region

    ''' <summary>
    ''' 
    ''' metoda ktora zisti ci existuje nejaky subor formularu
    ''' </summary>
    ''' <param name="pModulName"></param>
    ''' <param name="pUnitName"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function existForm(ByVal pModulName As String, ByVal pUnitName As String) As Boolean
        Dim frm As String
        frm = Me.aPathDestination + "\" + Me.aProjectName + "\" + aFileNames.mFolderModules + "\" + pModulName + "\" + aFileNames.mPrefixFrm + pUnitName

        If (My.Computer.FileSystem.FileExists(frm + aFileNames.mExtensionResx) = False) Then
            Return False
        End If
        If (My.Computer.FileSystem.FileExists(frm + aFileNames.mExtensionDesigner) = False) Then
            Return False
        End If
        If (My.Computer.FileSystem.FileExists(frm + aFileNames.mExtensionVBSource) = False) Then
            Return False
        End If
        Return True
    End Function

    ''' <summary>
    ''' metoda ktora zisti ci existuje Solution
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function existSolution() As Boolean
        Dim solutionPath As String
        solutionPath = Path.Combine(Me.aPathDestination, aSolutionName + aFileNames.mExtensionSln)
        Return My.Computer.FileSystem.FileExists(solutionPath)
    End Function


End Class
